import React from 'react'

import reducer, {
  ERROR_MODAL_SHOW,
  ERROR_MODAL_HIDE,
  errorModal,
  errorModalHide,
  ERROR_ALERT_SHOW,
  ERROR_ALERT_HIDE,
  errorAlert,
  errorAlertHide,
  MODAL_HIDE,
  MODAL_SHOW,
  modal,
  modalHide,
} from 'modules/system'
import configStore from 'configStore'

const store = configStore(reducer)

it('system action -> ERROR_MODAL_SHOW', () => {
  const action = store.dispatch(errorModal(''))

  expect(action.type).toBe(ERROR_MODAL_SHOW)
  expect(action).toMatchSnapshot()
})

it('system action -> ERROR_MODAL_HIDE', () => {
  const action = store.dispatch(errorModalHide())

  expect(action.type).toBe(ERROR_MODAL_HIDE)
  expect(action).toMatchSnapshot()
})

it('system action -> ERROR_ALERT_SHOW', () => {
  const action = store.dispatch(errorAlert(''))

  expect(action.type).toBe(ERROR_ALERT_SHOW)
  expect(action).toMatchSnapshot()
})

it('system action -> ERROR_ALERT_HIDE', () => {
  const action = store.dispatch(errorAlertHide())

  expect(action.type).toBe(ERROR_ALERT_HIDE)
  expect(action).toMatchSnapshot()
})

it('system reducer/ERROR_MODAL_SHOW', () => {
  const nextState = reducer({}, errorModal(''))

  expect(nextState).toMatchSnapshot()
})

it('system reducer/ERROR_MODAL_HIDE', () => {
  const nextState = reducer({}, errorModalHide())

  expect(nextState).toMatchSnapshot()
})

it('system action MODAL_SHOW', () => {
  const action = modal(() => <div>Hello Modal</div>, {
    data: 'data',
  })
  const nextState = reducer({}, action)

  expect(action.type).toBe(MODAL_SHOW)
  expect(nextState).toMatchSnapshot()
})

it('system action MODAL_HIDE', () => {
  const action = modalHide()
  const nextState = reducer({}, action)

  expect(action.type).toBe(MODAL_HIDE)
  expect(nextState).toMatchSnapshot()
})
